import { getViewRecords } from "@/api/user.js";

export default {
  data() {
    return {
      pageView: {
        list: [],
        current: 0,
        pageSize: 10,
        pageNo: 1,
        total: 0,
        visible: false
      }
    };
  },
  methods: {
    getPageViewData(page) {
      if (page) {
        this.pageView.pageNo = page;
      }

      getViewRecords({
        params: {
          anchorId: this.pageView.anchorId,
          pageNo: this.pageView.pageNo,
          pageSize: this.pageView.pageSize
        }
      }).then(res => {
        this.pageView.visible = true;
        this.pageView.list = res.data.data.list;
        this.pageView.total = res.data.data.pagination.total;
      });
    },
    getPageView(row) {
      this.pageView = {
        list: [],
        anchorId: row.anchorId,
        current: 0,
        pageSize: 10,
        pageNo: 1,
        total: 0,
        visible: true
      };
      this.getPageViewData();
    }
  }
};
